package cni.tcast.dubbo.consumer;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itcast.excel.interfaces.HelloDubbo;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RequestMapping("/dubbo")
@Controller
public class TestDubbo {
    @Reference(version = "1.0.0", timeout = 30000)
    private HelloDubbo helloDubbo;

    @RequestMapping("")
    public void dubbo(HttpServletResponse response) {
        String s = helloDubbo.testDubbo("陈彰坤");
        try {
            response.setHeader("Content-type", "text/html;charset=UTF-8");
            response.setCharacterEncoding("UTF-8");
            response.setHeader("refresh", "5;http://localhost:9008/dubbo");
            response.getWriter().write(s);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
